
package net.atremmedia.gwt.actionjava.examples.mouse.samples;

import net.atremmedia.gwt.actionjava.examples.AJExample;
import net.atremmedia.gwt.actionjava.examples.frame.AJExampleOverview;
import actionjava.display.Graphics;
import actionjava.display.Shape;
import actionjava.events.mouse.MouseEvent;
import actionjava.events.mouse.MouseEvent.MouseEventType;
import actionjava.events.mouse.StageDownHandler;
import actionjava.events.mouse.StageMoveHandler;
import actionjava.events.mouse.StageUpHandler;
import actionjava.geom.Color;
import com.allen_sauer.gwt.log.client.Log;

public class MouseExample1 extends AJExample
{
	public static final String NAME = "MouseExample 1";
	public static final String DESCRIPTION = "Description";
	public static final String EXAMPLE_SRC = "https://code.google.com/p/gwt-actionjava/source/browse/trunk/aj-examples/aj-examples-mouse/src/main/java/net/atremmedia/gwt/actionjava/examples/mouse/samples/MouseExample1.java";

	private Shape testFigure;

	public MouseExample1(AJExampleOverview base)
	{
		super(NAME, DESCRIPTION, EXAMPLE_SRC, base);
	}

	@Override
	public void run()
	{
		testFigure = new Shape();
		Graphics graphs = testFigure.getGraphics();
		graphs.beginFill(Color.getRGB(0xFF0000));
		graphs.drawCircle(50, 50, 50);
		graphs.endFill();
		testFigure.setCacheAsBitmap(true);
		addChild(testFigure);

		addEventListener(MouseEventType.STAGE_MOUSE_DOWN, new StageDownHandler()
		{
			@Override
			protected void stageDownHandler(MouseEvent event)
			{
				Log.fatal("Stage Down");
			}
		});

		addEventListener(MouseEventType.STAGE_MOUSE_UP, new StageUpHandler()
		{

			@Override
			protected void stageUpHandler(MouseEvent event)
			{
				Log.fatal("Stage UP");
			}
		});

		addEventListener(MouseEventType.STAGE_MOUSE_MOVE, new StageMoveHandler()
		{
			@Override
			protected void stageMoveHandler(MouseEvent event)
			{
				Log.fatal("Stage Move x: " + event.getRawX() + " y: " + event.getRawY());
			}
		});
	}
}
